﻿using System;
using uForum.Businesslogic;

namespace uForum.usercontrols.uForum
{
	public partial class DBInstaller : System.Web.UI.UserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (Data.SqlHelper.Utility.GetType().ToString() == "umbraco.DataLayer.SqlHelpers.SqlServer.SqlServerUtility")
			{
				WrongDbPanel.Visible = false;
			}
			else
			{
				StartPanel.Visible = false;
			} 
			DonePanel.Visible = false;
		}

		protected void installButton_Click(object sender, EventArgs e)
		{

			//Do DB stuff
		    string sql = DBInstallScripts.MSSQLServer;

			try
			{
				Data.SqlHelper.ExecuteNonQuery(sql);
			}
			catch (Exception ex)
			{
				completemessagelabel.Text = "The database failed to install properly. Errormessage: " + ex.ToString();    
			}

			StartPanel.Visible = false;
			DonePanel.Visible = true;
		}
	}
}